#include <iostream>
#include <queue>
#include <vector>
using namespace std;

const int kMaxN = 2e5 + 10;

vector<int> g[kMaxN];
queue<int> que[kMaxN];
int dis[kMaxN];

void BFS(int n) {
  for (int h = n; h; h--) {
    for (; !que[h].empty(); que[h].pop()) {
      int u = que[h].front();

      if (dis[u] != h) {
        continue;
      }
      for (int v : g[u]) {
        if (dis[v] < h - 1) {
          que[h - 1].emplace(v);
          dis[v] = h - 1;
        }
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m, k;

  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    g[u].emplace_back(v);
    g[v].emplace_back(u);
  }

  fill(dis, dis + n + 1, -1);
  for (int i = 0; i < k; i++) {
    int p, h;

    cin >> p >> h;
    que[h].emplace(p);
    dis[p] = h;
  }
  BFS(n);
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (dis[i] >= 0) {
      ans++;
    }
  }
  cout << ans << "\n";
  for (int i = 1; i <= n; i++) {
    if (dis[i] >= 0) {
      cout << i << " ";
    }
  }
  return 0;
}